<template>
  <div class="nav-container">
    <el-menu :default-active="activeIndex" mode="horizontal" class="nav-menu">
      <div class="nav-left">
        <div class="logo" @click="goToHome" style="cursor: pointer;">
          <img src="@/assets/logo.png" alt="学了喵">
          <span>学了喵</span>
        </div>
        <div class="search-box">
          <input type="text" placeholder="输入想学习的内容..." v-model="searchText">
          <button><i class="el-icon-search"></i></button>
        </div>
      </div>
    </el-menu>
    
    <div class="auth-container">
      <el-dropdown trigger="click" class="lang-dropdown">
        <span class="lang-trigger">
          <i class="el-icon-global" style="margin-right: 4px;">🌍</i>
          {{ currentLang }}
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>简体中文</el-dropdown-item>
            <el-dropdown-item>English</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <router-link to="/login" class="nav-btn login-btn">登录</router-link>
      <router-link to="/register" class="nav-btn register-btn">注册</router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: 'NavBar',
  data() {
    return {
      activeIndex: '1',
      searchText: '',
      currentLang: '简体中文'
    }
  },
  methods: {
    goToRegister() {
      window.location.href = '/register'
    },
    goToHome() {
      this.$router.push('/')
    }
  }
}
</script>

<style scoped>
.nav-container {
  width: 100%;
  max-width: 1920px;  /* 添加最大宽度限制 */
  height: 60px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: fixed;
  top: 0;
  left: 50%;  /* 添加居中定位 */
  transform: translateX(-50%);  /* 添加居中定位 */
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
}

.nav-menu {
  border: none;
  height: 100%;
  display: flex;
  align-items: center;  /* 添加垂直居中 */
}

.nav-left {
  height: 100%;  /* 修改高度 */
  display: flex;
  align-items: center;
  gap: 40px;
}

.auth-container {
  height: 100%;  /* 添加高度 */
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: bold;
  color: #6d28d2;
}

.logo img {
  height: 32px;
}

.search-box {
  display: flex;
  align-items: center;
  background: #f3f4f6;
  border-radius: 20px;
  padding: 6px 16px;
}

.search-box input {
  width: 240px;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
}

.search-box button {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
}

.auth-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-dropdown {
  margin-right: 20px;
}

.lang-trigger {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #666;
  font-size: 14px;
}

.lang-trigger:hover {
  color: #6d28d2;
}

.auth-btn {
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 14px;
}

.nav-btn {
  margin-left: 20px;
  cursor: pointer;
  text-decoration: none;
  color: #333;
}

.login-btn:hover {
  color: #6d28d2;
}

.register-btn {
  padding: 8px 20px;
  background-color: #6d28d2;
  color: white;
  border-radius: 4px;
}

.register-btn:hover {
  opacity: 0.9;
}
/* 删除 .explore-item 相关样式 */
</style>